<template>
  <div id="table">
      <div v-title>{{title}}</div>
      <div class="pd10 tb-title">
        <div class="tb-date">
            <div class="tb-date-left">当前查询日期:</div>
            <yd-datetime type="date" v-model="datetime" slot="left"  class="tb-date-right c2" :callback="changeDate"></yd-datetime>
        </div>
        <yd-flexbox>
            <yd-flexbox-item>收费渠道</yd-flexbox-item>
            <div class="tb-title-center">账目情况</div>
            <yd-flexbox-item>状态</yd-flexbox-item>
        </yd-flexbox>
      </div>
      <div class="pd10 tb-contain">
        <yd-flexbox class="tb-contain-li" v-for="(l,key) in list" :key="key">
            <yd-flexbox-item>
               <strong class="li-bba">{{l.name}}</strong> 
            </yd-flexbox-item>
            <div class="tb-contain-center">
                <div class="center-partone b1">收费系统</div>
                <p>
                    <span class="fl">总笔数</span>
                    <span class="fr c1">{{l.WCount}}</span>
                </p>
                <p>
                    <span class="fl">总金额</span>
                    <span class="fr c2">{{l.WTotal}}</span>
                </p>
                <div class="center-partone b2" style="margin-top:5px">代收方</div>
                <p>
                    <span class="fl">总笔数</span>
                    <span class="fr c3">{{l.BCount}}</span>
                </p>
                <p>
                    <span class="fl">总金额</span>
                    <span class="fr c4">{{l.BTotal}}</span>
                </p>
            </div>
            <yd-flexbox-item>
                <strong class="li-bba c1" v-if="l.State == 0">已平帐</strong>
                <strong class="li-bba c2" v-if="l.State == 1">未平帐</strong>
                <strong class="li-bba c4" v-if="l.State == 2">无对账文件</strong>
            </yd-flexbox-item>
        </yd-flexbox>
      </div>
  </div>
</template>

<script>
export default {
  name: "table",
  data() {
    return {
      title: "",
      company: "",
      list: [],
      datetime: ""
    };
  },
  methods: {
    GetDay() {
      var today = new Date();
      var yesterday_milliseconds = today.getTime() - 1000 * 60 * 60 * 24;
      var yesterday = new Date();
      yesterday.setTime(yesterday_milliseconds);
      var strYear = yesterday.getFullYear();
      var strDay = yesterday.getDate();
      var strMonth = yesterday.getMonth() + 1;
      if (strMonth < 10) {
        strMonth = "0" + strMonth;
      }
      var strYesterday = strYear + "-" + strMonth + "-" + strDay;
      this.datetime = strYesterday;
    },
    changeDate() {
        this.setData();
    },
    setData() {
      let data = {
        method: "querywarmboaccount",
        Date: this.datetime,
        company: this.company
      };
      this.$dialog.loading.open("稍等片刻...");
      this.axios
        .post(
          "https://qy.heatingpay.com/handler/northsoftbigdataservice.ashx",
          data
        )
        .then(res => {
          this.$dialog.loading.close();
           if(JSON.stringify(res) == '{}'){
                this.$dialog.alert({ mes: "暂无结果" });
                return;
           }
          let arr = new Array();
          let f;
          for (f in res) {
            if (f != "") {
              let ob = new Object();
              ob = res[f];
              ob["name"] = f;
              arr.push(res[f]);
            }
          }
          this.list = arr;
        });
    }
  },
  created() {
    this.title = sessionStorage.type;
    this.company = sessionStorage.company;
    this.GetDay();
    this.setData();
  }
};
</script>

<style>
.pd10 {
  padding: 10px;
}
.tb-title {
  font-size: 14px;
  text-align: center;
}
.tb-contain {
  background: #fff;
  text-align: center;
}
.tb-contain-li {
  border: 1px solid #d9d9d9;
  padding: 10px 0;
  margin-bottom: 10px;
}
.tb-contain-center {
  padding: 0 10px;
  width: 180px;
  font-size: 13px;
  border-left: 1px solid #d9d9d9;
  border-right: 1px solid #d9d9d9;
}
.center-partone {
  width: 100%;
  color: #fff;
  padding: 3px 0;
  margin-bottom: 5px;
  float: left;
}
.tb-contain-center p {
  display: block;
  width: 100%;
  float: left;
  height: 24px;
  line-height: 24px;
  padding: 0 10px;
}
.c1 {
  color: #31badc;
}
.c2 {
  color: #df4b63;
}
.c3 {
  color: #43caca;
}
.c4 {
  color: #fb6151;
}
.b1 {
  background: #31badc;
}
.b2 {
  background: #9eca13;
}
.fl {
  float: left;
}
.fr {
  float: right;
}
.li-bba {
  font-size: 13px;
}
.tb-title-center {
  width: 180px;
  border-left: 1px solid #ffffff;
  border-right: 1px solid #ffffff;
}
.tb-date {
  padding: 0 0 10px 0;
  border-bottom: 1px solid #fff;
  margin-bottom: 10px;
}
.tb-date-left {
  display: inline-block;
}
.tb-date-right {
  display: inline-block;
  width: 66% !important;
  text-align: left;
}
.tb-date-btn {
  display: inline-block;
  width: 10%;
}
</style>
